﻿@{
    ViewData["Title"] = new string[] { "广告管理" };
    TempData["subMenu-check"] = new string[] { "Public", "ManageAdvertising" };
    var PositionId = ViewData.Get<long>("PositionId", 0);
    IEnumerable<SelectListItem> positionSelectList = ViewData.Get<IEnumerable<SelectListItem>>("positionSelectList", null);
}
<div class="row tn-page-heading tn-mb-10">
    <div class="col-lg-12">
        <h3>广告管理</h3>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-body ">
        <div class="form-inline tn-tool-column text-right row">
            <div class="form-group col-xs-3 text-left">
                <a class="btn btn-default edit-user" href="@SiteUrls.Instance()._EditAdvertising(null)"><i class="fa fa-plus"></i> 添加广告</a>
            </div>
            <div class="form-group col-xs-8 text-right">
                <a class="a tn-mr-10" href="@SiteUrls.Instance().ManageAdvertisingPosition()">管理广告位</a>
                @if (positionSelectList != null)
                {

                    <select class="form-control" id="position" name="position">

                        @foreach (var item in positionSelectList)
                        {
                            <option title="@item.Text" value="@item.Value">@StringUtility.Trim(item.Text,20)</option>
                        }



                    </select>
                }

             
            </div>
        </div>
    </div>
</div>
<div class="panel panel-default">
    <div id="_listAdvertising" class="panel-body">
        @Html.Action("_ListAdvertising", "ControlPanel")
    </div>
</div>

<script>
    require(['jquery'], function () {
           $("#position").change(function () {
            var position = $("#position option:selected").val();
            $.get("@CachedUrlHelper.Action("_ListAdvertising", "ControlPanel")", { positionId: position, requestTime: new Date().getTime() }, function (data) {
                if (data) {
                    $("#_listAdvertising").html(data);
                }
            })
        })
      })
</script>